﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WarriorRush.GameDynamics.Utilities;
using WarriorRush.GameDynamics;
using WarriorRush.UserInterface;

namespace WarriorRush
{
    public class SelectionManager
    {
        private Dictionary<Player, Dictionary<SelectionType, SelectionHandler>> AllSelections;
        
        
        public SelectionManager()
        {
            AllSelections = new Dictionary<Player, Dictionary<SelectionType, SelectionHandler>>{
                {Player.one, new Dictionary<SelectionType,SelectionHandler>()},
                {Player.two, new Dictionary<SelectionType,SelectionHandler>()}

            };
        }

        public SelectionHandler GetCurrentSelections(Player player, SelectionType selection)
        {
            return AllSelections[player].ContainsKey(selection) ? AllSelections[player][selection] : null;
        }


        
        public void AddSelectionOptions(Player player, SelectionType type, SelectionHandler selections)
        {
            if (AllSelections[player].ContainsKey(type))
                AllSelections[player][type] = selections;
            else
                AllSelections[player].Add(type, selections);
        }


        public void ClearAll()
        {
            foreach (var player in AllSelections)
            {
                
                foreach (var selection in player.Value.Keys.ToList())
                {
                    player.Value[selection] = null;
                }
            }
        }
    }
}
